package util

import (
	"os"
	"path"
	"strings"
)

// DeleteFileSuffix  获取文件的后缀名
func DeleteFileSuffix(filePath string) string {
	if strings.Contains(filePath, "\\") {
		filePath = strings.ReplaceAll(filePath, "\\", "/")
	}
	fileNameWithSuffix := path.Base(filePath)

	fileSuffix := path.Ext(fileNameWithSuffix)

	fileName := strings.TrimSuffix(fileNameWithSuffix, fileSuffix)
	return fileName
}

// IsExist  判断文件是否存在
func IsExist(filePath string)bool{
	_, err := os.Stat(filePath)
	if err != nil{
		if os.IsExist(err){
			return true
		}
		if os.IsNotExist(err){
			return false
		}
		return false
	}
	return true
}
